package relative

import (
	. "bysy-gin/handler"
	"bysy-gin/model"
	"github.com/gin-gonic/gin"
	"strconv"
)

func RelativeTest(c *gin.Context) {
	//通过作者找文章
	//id, err := strconv.Atoi(c.Param("id"))
	//if err != nil {
	//	SendResponse(c, 1003, "数据转换失败", err)
	//	return
	//}
	//var a model.Author
	//a.ID = uint(id)
	//if err := a.GetArticle(); err != nil {
	//	SendResponse(c, 1012, "获取文章失败", err)
	//	return
	//}
	//SendResponse(c, 0, "success!", a)

	//通过文章找作者
	id, err := strconv.Atoi(c.Param("id"))
	if err != nil {
		SendResponse(c, 1003, "数据转换失败", err)
		return
	}
	var a model.Article
	a.ID = uint(id)
	if err := a.GetArticleType(); err != nil {
		SendResponse(c, 1012, "获取文章失败", err)
		return
	}

	//fmt.Println(a.Author.Name)
	SendResponse(c, 0, "success!", a)
}
